﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BuyRitmus.Negocio.BLL;
using BuyRitmus.Negocio.Model;

namespace BuyRitmus.Web.administracao.eventos
{
    public partial class detalhes : System.Web.UI.Page
    {
        public EventoDTO Evento { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {   
            int idEvento = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                idEvento = Convert.ToInt32(Request.QueryString["id"]);
                EventoBLL eventoBLL = new EventoBLL();
                this.Evento = eventoBLL.Pegar(idEvento);
            }
            else
                throw new Exception("Código do evento não informado.");
        }

        public string FormatarDataEvento(DateTime data)
        {
            DateTimeFormatInfo dfti = new CultureInfo("pt-BR", false).DateTimeFormat;
            data = Convert.ToDateTime(data, dfti);

            string dataFinal = data.Day.ToString() + " de " + FormatarPrimeiraMaiuscula(data.ToString("MMMM").Substring(0, 3)) + ", " + FormatarPrimeiraMaiuscula(dfti.GetDayName(data.DayOfWeek).Split('-')[0]) + ", " + data.ToString("HH:mm") + " hrs.";
            return dataFinal;
        }

        private string FormatarPrimeiraMaiuscula(string s)
        {
            if (string.IsNullOrEmpty(s))
                return string.Empty;
            return char.ToUpper(s[0]) + s.Substring(1).ToLower();
        }
    }
}